﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace C12_Ex02_Shaked_032675316_Itay_032511057
{
    public enum PictureButtonStates
    {
        IN,
        OUT
    }

    public partial class PictureButton : PictureBox
    {
        protected PictureButtonStates m_State;

        public PictureButton()
        {
            m_State = PictureButtonStates.OUT;
            InitializeComponent();
        }

        protected override void OnPaint(PaintEventArgs pe)
        {
            base.OnPaint(pe);

            if (this.Enabled && m_State == PictureButtonStates.IN)
            {
                SolidBrush brush = new SolidBrush(Color.FromArgb(100, Color.Yellow));
                Region region = new Region(pe.ClipRectangle);
                pe.Graphics.FillRegion(brush, region);
            }
        }

        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            m_State = PictureButtonStates.IN;
            Invalidate();
        }

        protected override void OnMouseLeave(EventArgs e)
        {
            base.OnMouseLeave(e);
            m_State = PictureButtonStates.OUT;
            Invalidate();
        }
    }
}
